<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        ul,
        li {

            list-style: none;
        }

        ul {
            display: flex;
            border: 1px solid red;
            justify-content: space-evenly;
            padding: 10px 0;
        }

        ul li {
            width: 24%;
            border: 1px solid #ccc;
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 10px 0;
            cursor: pointer;

        }

        ul li img {
            width: 90%;
        }

        ul li p {
            width: 90%;
            margin: 5px;
        }
    </style>
</head>

<body>
    <ul id="goods">
        <!-- <li class="goods1"><img src="../images/g1.jpg">
            <p>姓名：阿联酋美女1号</p>
            <p>价格：20</p>
            <p>年龄：20</p>
        </li> -->
    </ul>
    <script>
         var goodlist = [
            { id: 111, url: 'images/g1.jpg', name: '阿联酋美女1号', price: 1998, age: 20 },
            { id: 22, url: 'images/g2.jpg', name: '阿联酋美女2号', price: 98, age: 18 },
            { id: 3325, url: 'images/g3.jpg', name: '阿联酋美女3号', price: 998, age: 22 },
            { id: 4, url: 'images/g4.jpg', name: '阿联酋美女4号', price: 9.8, age: 24 },
            { id: 5, url: 'images/g3.jpg', name: '阿联酋美女5号', price: 9888, age: 18 }
        ]
        var goods = document.querySelector('#goods')
        goodlist.forEach(function(item,index){
            goods.innerHTML += '<li class="goods1" idx="' + item.id + '"> <img src="'+ item['url'] +'">' +
                '<p>姓名：'+ item.name +'</p>' +
                '<p>价格:'+ item['price'] +'</p>' +
                '<p>年龄：'+ item.age +'</p>' +
                '</li>'
        })
        var list = document.querySelectorAll('.goods1')
        list.forEach(function(item,index){
            item.onclick = function(){
                open('detail.html?id=' + this.getAttribute('idx'))
            }
        })
    </script>
</body>
</html>